/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author TQNINH
 */
public class TransferManager implements Runnable {
    CustomerAccount src;
    CustomerAccount des;
    int transferCount;
    double amt;
    
    public TransferManager(CustomerAccount s, CustomerAccount d, double a){
        this.src = s;
        this.des = d;
        amt = a;
    }
    
    public void run(){
        src.displayDetails();
        des.displayDetails();
        System.out.println("Total: " + (src.getBanlance() + des.getBanlance()));
        if(amt > 0 && amt <= src.getBanlance()) {
            src.setBalance(src.getBanlance() - amt);
            des.setBalance(des.getBanlance() + amt);
            transferCount++;
            System.out.println("Transfer" + (transferCount - 1) + "success!");
            src.displayDetails();
            des.displayDetails();
            System.out.println("Total: " + (src.getBanlance() + des.getBanlance()));
            System.out.println("End");
        } else {
            System.out.println("Cannot transfer!");
        }
    }
}
